<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>3-4-表单数据的双向绑定-组合式</title>
</head>

<body>




  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>

  <div id="app">
    <h1>表单绑定</h1>
    <input v-model.lazy="textField" />
    <h2>您输入的是{{textField}}（lazy修饰）</h2>

    <input v-model.trim="n_textField" />
    <h2>您输入的是{{n_textField}}(trim修饰)</h2>

    <h1>复选框</h1>
    <input type="checkbox" v-model="checkbox" />
    <h2> 布尔值:{{checkbox}}</h2>

    <hr />

    <h1>复选框绑定</h1>
    <input type="checkbox" name="aihao" value="足球" v-model="checkList" />足球
    <input type="checkbox" name="aihao" value="篮球" v-model="checkList" />篮球
    <input type="checkbox" name="aihao" value="排球" v-model="checkList" />排球
    <h2>您选中的是：{{checkList}}</h2>

    <hr />

    <h1>单选框绑定</h1>
    <input type="radio" value="男" v-model="sex" />男
    <input type="radio" value="女" v-model="sex" />女
    <p>您选中的是：{{sex}}</p>

    <h1>单选-选择列表</h1>
    <select v-model="select">
      <option>足球</option>
      <option>排球</option>
      <option>篮球</option>
    </select>
    <p>您单选的是：{{select}}</p>

    <h1>单选-多选列表</h1>
    <select v-model="selectList" multiple>
      <option>足球</option>
      <option>排球</option>
      <option>篮球</option>
    </select>
    <p>您多选的是：{{selectList}}</p>



  </div>

  <script>
    const App = Vue.createApp({
      setup() {
        const textField = Vue.ref("")
        const n_textField = Vue.ref("")
        const checkbox = Vue.ref(false)
        let checkList = Vue.ref([])



        const sex = Vue.ref("")
        const select = Vue.ref("")
        const selectList = Vue.ref([])
        return {
          textField,
          n_textField,
          checkbox,
          checkList,
          sex,
          select,
          selectList,
        }
      }
    })

    App.mount("#app")
  </script>




</body>

</html>